<template>
  <div>
    <div>我是父组件</div>
    <button @click="show1">点击显示子组件</button>
    <child v-if="show" @parent1="parent1()" :parent1="parent1" :demo="demo"></child>
    <hr/>
  </div>
</template>

<script>
import child from "./child";
export default {
  data() {
    return {
      show: false,
      demo:'父组件传值'
    };
  },
  components: {
    child,
  },
  methods: {
    show1() {
      this.show = !this.show;
    },
    parent1(value) {
      alert("我是父组件方法");
      if(value){
          alert(value)
      }
    },
  },
};
</script>

<style>
</style>